
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets" template="/template/main.xhtml">

	<ui:define name="body">
		<h:form prependId="false" id="form">
		
			<p:fieldset style="width:98%; -webkit-border-radius: 8px; -moz-border-radius: 8px;border-radius: 8px;" legend="#{messages['filtrar']}" toggleable="true" toggleSpeed="500">	
				<h:panelGrid columns="2">

					<h:outputLabel value="#{messages['pedido.label.dataEntrega']}: " for="dataInicial" styleClass="text-input" />
					<h:panelGrid columns="5">
						<p:calendar id="dataInicial" value="#{clienteExtratoRelatorioMB.dataInicial}"  
						   	pattern="#{messages['label.date.pattern']}" navigator="true" showButtonPanel="true"
						   	locale="#{currentLocale}" title="#{messages['pedido.alt.dataEntrega']}" />
						<p:message for="dataInicial" />
						
						<h:outputLabel value=" a " for="dataFinal" styleClass="text-input" />
						<p:calendar id="dataFinal" value="#{clienteExtratoRelatorioMB.dataFinal}"  
						   	pattern="#{messages['label.date.pattern']}" navigator="true" showButtonPanel="true"
						   	locale="#{currentLocale}" title="#{messages['pedido.alt.dataFinal']}" />
						<p:message for="dataFinal" />
						
					</h:panelGrid>
				</h:panelGrid>

				<p:commandButton value="#{messages['button.pesquisar']}" ajax="true" update="list" actionListener="#{clienteExtratoRelatorioMB.filtrar()}">
				</p:commandButton>

			</p:fieldset>

			<br />
			<br />

			<p:fieldset style="width:98%; -webkit-border-radius: 8px; -moz-border-radius: 8px;border-radius: 8px;" legend="Extrato do Cliente" toggleable="true" toggleSpeed="500" id="fieldset">	
				<div style="overflow: auto; width: 100%; height: 200;">
					<p:dataTable id="list" var="bean" value="#{clienteExtratoRelatorioMB.resultList}">

						<p:column style="font-size:12;" sortBy="#{bean.nomeCliente}">
							<f:facet name="header">#{messages['pedido.label.cliente']}</f:facet>
							<h:outputText value="#{bean.nomeCliente}" />
						</p:column>
		
						<p:column style="font-size:12;" sortBy="#{bean.saldoAnterior}">
							<f:facet name="header">Saldo devedor Anterior</f:facet>
							<h:outputText value="#{bean.saldoAnterior}" converter="bigDecimalConversor" />
						</p:column>
								
						<p:column style="font-size:12;" sortBy="#{bean.valorPedido}">
							<f:facet name="header">Valor dos Pedidos</f:facet>
								<h:outputText value="#{bean.valorPedido}" converter="bigDecimalConversor"  />
								
						</p:column>
								
						<p:column style="font-size:12;" sortBy="#{bean.valorPagamento}">
							<f:facet name="header">Valor dos Pagamentos</f:facet>
							<h:outputText value="#{bean.valorPagamento}" converter="bigDecimalConversor"  />
						</p:column>
		
						<p:column style="font-size:12;" sortBy="#{bean.saldoPeriodo}">
							<f:facet name="header">Saldo no Período</f:facet>
							<h:outputText value="#{bean.saldoPeriodo}" converter="bigDecimalConversor"/>
						</p:column>

						<p:column style="font-size:12;" sortBy="#{bean.saldoPeriodo}">
							<f:facet name="header">Valor Total Extrato</f:facet>
							<h:outputText value="#{bean.saldoExtrato}" converter="bigDecimalConversor"/>
						</p:column>
					</p:dataTable>
				</div>

			</p:fieldset>
			
			<h:panelGrid columns="2">   
		         <h:commandLink immediate="true">  
		            <input type="button" title="Exportar" value="Exportar"/>  
		            <p:dataExporter postProcessor="#{clienteExtratoRelatorioMB.postProcessXLS}" type="xls" target="list" fileName="dados_exportados"  />  
		        </h:commandLink>
			</h:panelGrid>

		</h:form>

	</ui:define>
</ui:composition>